<extend name="Index/index" />
<block name="center">
<div class="panel panel-blue">
    <div class="panel-heading">管理员修改</div>
        <div class="panel-body pan">
                <form action="{:U('Admin/Uadmin/update')}" class="form-horizontal" method="post">
                    <div class="form-actions top">
                        
                    </div>
                    <div class="form-body pal">
                        <div class="form-group">
                            <label for="inputAddress" class="col-md-3 control-label">用户名称 <span class="require">*</span>
                            </label>
                            <div class="col-md-9">
                                <div class="input-icon right" ><i class="fa fa-location-arrow"></i>
                                    <div style="float:left"><input type="text" value="{$info[0]['ausername']}" class="form-control" name="ausername" id="Uadmin" style="width:300px"></div><div style="float:left"><span id="con" error="输入的用户名已存在" success="√" kong="用户名格式错误" style="font-size:20px"></span></div>
                                </div>
                            </div>
                        </div>
                         <div class="form-group">
                            <label for="inputAddress" class="col-md-3 control-label">管理权限<span class="require">*</span>
                            </label>
                            <div class="col-md-9">
                                <div class="input-icon right" ><i class="fa fa-location-arrow"></i>
                                    <div style="float:left"><select class="form-control" name="group_id" style="width:300px">
                                        <foreach name="rolesinfo" item="vo" > 
                                        <option value="{$vo['id']}" <if condition="$vo['id'] eq $groupinfo[0]['id'] ">selected  </if>>{$vo['title']}</option>
                                        </foreach>
                                    </select></div><div style="float:left"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="selGender">状态 <span class="require">*</span>
                            </label>
                            <div class="col-md-9">
                                <div class="radio">
                                    <label class="radio-inline">
                                        <div class="iradio_minimal-grey" style="position: relative;"><input type="radio" name="aroles" value="0"  <if condition="$info[0]['aroles'] eq 0 ">checked  </if>  style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div>&nbsp; 正常
                                    </label>
                                    <label class="radio-inline">
                                        <div class="iradio_minimal-grey" style="position: relative;"><input type="radio" name="aroles" value="1" <if condition="$info[0]['aroles'] eq 1 ">checked  </if> style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div>&nbsp; 禁用
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <input type="hidden" name="id" value="{$info['0']['id']}">
                            <button type="submit" class="btn btn-primary">修改</button>&nbsp;
                            <button type="reset" class="btn btn-green">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
            <script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
        $(function(){
            var ustatu = false;
            // var pstatu = false;
            //判断用户名
            $('#Uadmin').blur(function(){
                //匹配正则
                var reg = /^\w{6,18}$/;//6~18位

                var uadmin = $(this).val();
                var res =  reg.test(uadmin);
                // alert(res);
                if(res == ''){
                    // alert(2);
                    // alert(1);
                        var re = $('#con').attr('kong');
                        // console.log(re);
                        $('#con').html(re).css('color','red');
                        ustatu = false;
                        // die();
                }else{
                        // alert(res);
                        // $.post('{:U("Admin/Uadmin/ajax")}',{'res':uadmin},function(data){
                        //     // alert(data);
                        //     if(data == 1){
                        //         // alert(1);
                        //         var re = $('#con').attr('success');
                        //         // console.log(re);
                        //         $('#con').html(re).css('color','blue');
                        //         ustatu = true;
                        //     }else{
                        //         // alert(0);
                        //         var re = $('#con').attr('error');
                        //         $('#con').html(re).css('color','red');
                        //         ustatu = false;
                        //         // console.log(re);
                        //     }
                        // });
                        $.ajax({
                            url:'{:U("Admin/Uadmin/ajax")}',
                            data:{'res':uadmin},
                            type:'POST',
                            success: function(data){
                                if(data == 1){
                                    // alert(1);
                                    var re = $('#con').attr('success');
                                    // console.log(re);
                                    $('#con').html(re).css('color','blue');
                                    ustatu = true;
                                }else{
                                    // alert(0);
                                    var re = $('#con').attr('error');
                                    $('#con').html(re).css('color','red');
                                    ustatu = false;
                                    // console.log(re);
                                }
                            },
                            async: false//是否异步  x.open('GET','1.php', true);
                        });


            
                    }

        
            })
            $('.form-horizontal').submit(function(){
                $('#Uadmin').trigger('blur');
                if(ustatu ){ 
                    return true;
                }else{
                    return false;
                }
            })
        })
        </script>

</block>